$.fn.myswipe = function(direction, start, cb) {
    //滑动的方向
    var direction = direction;
    //滑动的阈值
    var threshold = 30;

    var move = false;
    var x, y, startX, startY;
    $(this).on('touchstart', touchstartHandle);
    $(this).on('touchmove', touchmoveHandle);
    $(this).on('touchend', touchendHandle);

    function touchstartHandle(e) {
        e.preventDefault();
        startX = e.changedTouches[0].clientX;
        startY = e.changedTouches[0].clientY;
        move = true;
        if (typeof start == "function") {
            start.call(this, null);
        }
    }

    function touchmoveHandle(e) {
        e.preventDefault();
        if (move) {
            x = e.changedTouches[0].clientX;
            y = e.changedTouches[0].clientY;
        }
    }

    function touchendHandle(e) {
        e.preventDefault();
        x = e.changedTouches[0].clientX;
        y = e.changedTouches[0].clientY;
        if (direction == 'swipeUp' && startY - y > 30) {
            swipeUp();
        }
        if (direction == 'swipeDown' && y - startY > 30) {
            swipeDown();
        }
        if (direction == 'swipeLeft' && startX - x > 30) {
            swipeLeft();
        }
        if (direction == 'swipeRight' && x - startX > 30) {
            swipeRight();
        }

        move = false;
    }

    function swipeUp() {
        cb.call(this, this);
    }

    function swipeDown() {
        cb.call(this, this);
    }

    function swipeLeft() {
        cb.call(this, this);
    }

    function swipeRight() {
        cb.call(this, this);
    }
}